/*
 *   Copyright 2023 <a href="mailto:asialjim@hotmail.com">Asial Jim</a>
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */
package com.asialjim.encommunicate.rsa.management.pojo;

import jakarta.validation.constraints.NotBlank;
import lombok.Data;

import java.io.Serial;
import java.io.Serializable;
import java.util.Optional;

/**
 * 保存应用的加解密配置信息
 *
 * @author Copyright © <a href="mailto:asialjim@hotmail.com">Asial Jim</a>   Co., LTD
 * @version 1.0
 * @since 2023/2/28, &nbsp;&nbsp; <em>version:1.0</em>, &nbsp;&nbsp; <em>java version:17</em>
 */
@Data
public class AppEnDecryptInfo implements Serializable {

    @Serial
    private static final long serialVersionUID = -2053741565139678214L;

    /**
     * 应用编号
     */
    @NotBlank(message = "应用编号不能为空")
    private String appid;

    /**
     * 应用名称
     */
    private String name;

    /**
     * 通讯请求是否开启加密
     */
    private Boolean reqEncEnable;

    /**
     * 通讯响应是否开启加密
     */
    private Boolean resEncEnable;

    public Boolean getReqEncEnable() {
        return Optional.ofNullable(this.reqEncEnable).orElse(Boolean.TRUE);
    }

    public Boolean getResEncEnable() {
        return Optional.ofNullable(this.resEncEnable).orElse(Boolean.TRUE);
    }

    /**
     * 服务端私钥: 用于请求密文解密，响应结果加签
     */
    private String serverPriKey;

    /**
     * 服务端公钥: 用于请求签名验签，响应结果加密
     */
    private String serverPubKey;

    /**
     * 客户端私钥： 用于客户端请求加签，响应结果解密
     */
    private String clientPriKey;

    /**
     * 客户端私钥： 用于客户端请求加密，响应结果签名验签
     */
    private String clientPubKey;
}